home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
17 Bit Software 6: Level 6
/
17 Bit - Level 6 (1998)(Epic Marketing)[!].iso
/
quartz
/
q1082.dms
/
q1082.adf
/
src.lzh
/
Fig
/
intui.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-18
|
21KB
|
1,157 lines
#define ZOOMWIDTH 40
#define ZOOMHEIGHT 40
#include "fig.h"
#include "paintop.h"
#include "resources.h"
#include "const.h"
extern int figure_modified;
extern char current_file[];
extern int magnet_mode;
extern void (*canvas_locmove_proc)();
extern void (*canvas_leftbut_proc)();
extern void (*canvas_middlebut_proc)();
extern void (*canvas_rightbut_proc)();
extern void (*canvas_kbd_proc)();
extern void null_proc();
extern char_handler();
struct Window *figwin;
struct RastPort *RastPort;
typedef struct switch_struct
{
int on;
int group;
int x; /* Row 0 / 1 */
int y; /* Column 0 -> ? */
struct iconpic *icon;
int value;
int (*on_func)();
int (*off_func)();
int type;
} F_switch;
extern F_switch switches[];
struct TextAttr StandardFont =
{
(UBYTE *)"topaz.font",
8,
FS_NORMAL,
FPF_ROMFONT
};
struct NewScreen NewScreen =
{
0,0,640,STDSCREENHEIGHT,1,
0,1,
HIRES|LACE,
CUSTOMSCREEN,
(struct TextAttr *)&StandardFont,
(STRPTR)"FIG: Facility For Interactive Generation Of Figures",
(struct Gadget *)NULL,
(struct BitMap *)NULL
};
struct NewWindow NewWindow =
{
0,11,
640,501,
0,1,
RAWKEY | MOUSEBUTTONS | MOUSEMOVE | GADGETDOWN | MENUPICK | INTUITICKS,
ACTIVATE | BORDERLESS | BACKDROP | REPORTMOUSE,
(struct Gadget *)NULL,
(struct Image *)NULL,
(STRPTR)NULL,
(struct Screen *)NULL,
(struct BitMap *)NULL,
~0,~0,
~0,~0,
CUSTOMSCREEN
};
struct SmallMenu
{
UBYTE *Title;
UBYTE Command;
};
STATIC struct SmallMenu Menus[] =
{
{ "Undo", 'U' },
{ "Redisplay", 'R' },
{ "Remove All", 'E' },
{ "Open File...", 'O' },
{ "Save", 0 },
{ "Insert File...", 'I' },
{ "Save File As...", 'S' },
{ "Status", '?' },
{ "Save & Quit", 0 },
{ "Quit", 'Q' },
{ "Save As IFF-ILBM", 0 },
{ "Display Mode...", 'M' },
{ "Zoom Window", 'Z' },
};
struct ReqLib *ReqBase;
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Library *GadToolsBase;
struct Library *LayersBase;
extern struct ExecBase *SysBase;
struct IOStdReq *ConsoleRequest;
struct Library *ConsoleDevice;
struct MsgPort *InputPort;
struct IOStdReq *InputRequest;
struct Screen *Screen;
struct Window *Window,*AnotherWindow;
extern struct Window *ZoomWindow;
struct Process *ThisProcess;
APTR OldPtr;
UWORD *Sprite;
struct Menu *Menu;
struct TextFont *fig_font;
struct ReqFileRequester LoadFileRequest,SaveFileRequest;
UBYTE FileName1[FCHARS],FileName2[FCHARS];
UBYTE DirectoryName1[DSIZE],DirectoryName2[DSIZE];
UBYTE TempName[FCHARS+DSIZE];
STATIC BYTE MoveCount = 0;
extern APTR _ONGURU;
extern ULONG GetDisplayMode();
VOID
FlushMsg()
{
struct IntuiMessage *Massage;
while(Massage = (struct IntuiMessage *)GetMsg(Window -> UserPort))
ReplyMsg(Massage);
}
VOID
CloseWindowSafely(struct Window *Window)
{
struct IntuiMessage *IntuiMessage;
struct Node *Successor;
Forbid();
IntuiMessage = (struct IntuiMessage *)Window -> UserPort -> mp_MsgList . lh_Head;
while(Successor = IntuiMessage -> ExecMessage . mn_Node . ln_Succ)
{
if(IntuiMessage -> IDCMPWindow == Window)
{
Remove(IntuiMessage);
ReplyMsg((struct Message *)IntuiMessage);
}
IntuiMessage = (struct IntuiMessage *)Successor;
}
Window -> UserPort = NULL;
ModifyIDCMP(Window,NULL);
Permit();
CloseWindow(Window);
}
VOID
CloseAll()
{
ThisProcess -> pr_WindowPtr = OldPtr;
if(ConsoleRequest)
{
if(ConsoleRequest -> io_Device)
CloseDevice(ConsoleRequest);
FreeMem(ConsoleRequest,sizeof(struct IOStdReq));
ConsoleRequest = NULL;
}
if(InputRequest)
{
if(InputRequest -> io_Device)
CloseDevice(InputRequest);
DeleteStdIO(InputRequest);
InputRequest = NULL;
}
if(InputPort)
{
DeletePort(InputPort);
InputPort = NULL;
}
if(Screen)
ScreenToBack(Screen);
CloseZoomWindow();
if(AnotherWindow)
{
CloseWindowSafely(AnotherWindow);
AnotherWindow = NULL;
}
if(Window)
{
CloseWindow(Window);
Window = NULL;
}
if(Screen)
{
CloseScreen(Screen);
Screen = NULL;
}
if(Sprite)
{
FreeMem(Sprite,(17 + 2) * 2 * sizeof(UWORD));
Sprite = NULL;
}
if(Menu)
{
ClearMenu(Menu);
Menu = NULL;
}
if(fig_font)
{
CloseFont(fig_font);
fig_font = NULL;
}
ClearGadgets();
if(ReqBase)
{
PurgeFiles(&LoadFileRequest);
PurgeFiles(&SaveFileRequest);
CloseLibrary(ReqBase);
ReqBase = NULL;
}
if(LayersBase)
{
CloseLibrary(LayersBase);
LayersBase = NULL;
}
if(GadToolsBase)
{
CloseLibrary(GadToolsBase);
GadToolsBase = NULL;
}
}
VOID
GuruCleanup()
{
memcleanup();
mem_free();
CloseAll();
}
BYTE
OpenAll(struct Gadget *FirstGadget)
{
ThisProcess = (struct Process *)SysBase -> ThisTask;
OldPtr = ThisProcess -> pr_WindowPtr;
_ONGURU = GuruCleanup;
if(!(InputPort = (struct MsgPort *)CreatePort(NULL,0)))
return(FALSE);
if(!(InputRequest = (struct IOStdReq *)CreateStdIO(InputPort)))
return(FALSE);
if(OpenDevice("input.device",0,InputRequest,0))
return(FALSE);
if(!(ConsoleRequest = (struct IOStdReq *)AllocMem(sizeof(struct IOStdReq),MEMF_PUBLIC|MEMF_CLEAR)))
return(FALSE);
if(OpenDevice("console.device",CONU_LIBRARY,ConsoleRequest,0))
return(FALSE);
ConsoleDevice = &ConsoleRequest -> io_Device -> dd_Library;
if(!(ReqBase = (struct ReqLib *)OpenLibrary("req.library",0)))
return(FALSE);
if(!(LayersBase = OpenLibrary("layers.library",0)))
return(FALSE);
IntuitionBase = (struct IntuitionBase *)ReqBase -> IntuiLib;
GfxBase = (struct GfxBase *)ReqBase -> GfxLib;
if(!(Sprite = (UWORD *)AllocMem((17 + 2) * 2 * sizeof(UWORD),MEMF_CHIP|MEMF_CLEAR)))
return(FALSE);
if(!(fig_font = (struct TextFont *)OpenFont(&StandardFont)))
return(FALSE);
if(IntuitionBase -> LibNode . lib_Version >= 36)
{
struct Rectangle DisplayClip;
ULONG DisplayID;
LONG Height;
DisplayID = GetDisplayMode();
if(!(GadToolsBase = OpenLibrary("gadtools.library",36)))
return(FALSE);
if(!QueryOverscan(DisplayID,&DisplayClip,OSCAN_TEXT))
return(FALSE);
if((Height = (DisplayClip . MaxY - DisplayClip . MinY) + 1) < 480)
Height = 480;
Screen = (struct Screen *)OpenScreenTags(NULL,
SA_Height, Height,
SA_Overscan, OSCAN_TEXT,
SA_Depth, 1,
SA_Title, NewScreen . DefaultTitle,
SA_Font, &StandardFont,
SA_DisplayID, DisplayID,
SA_AutoScroll, TRUE,
TAG_DONE);
NewWindow . TopEdge = 12;
}
else
Screen = (struct Screen *)OpenScreen(&NewScreen);
if(!Screen)
return(FALSE);
NewWindow . Height = Screen -> Height - NewWindow . TopEdge;
NewWindow . Width = 96;
NewWindow . FirstGadget = FirstGadget;
NewWindow . Screen = Screen;
if(!(Window = (struct Window *)OpenWindow(&NewWindow)))
return(FALSE);
NewWindow . LeftEdge = 96;
NewWindow . Flags |= RMBTRAP;
NewWindow . IDCMPFlags = NULL;
NewWindow . FirstGadget = NULL;
NewWindow . Width = Screen -> Width - 96;
if(!(AnotherWindow = (struct Window *)OpenWindow(&NewWindow)))
return(FALSE);
AnotherWindow -> UserPort = Window -> UserPort;
ModifyIDCMP(AnotherWindow,RAWKEY | MOUSEBUTTONS | MOUSEMOVE | GADGETDOWN | MENUPICK | INTUITICKS);
ThisProcess -> pr_WindowPtr = (APTR)Window;
return(TRUE);
}
UBYTE *
DoFileRequest(UBYTE *Title,UBYTE *Buffer,BYTE DoSave)
{
struct ReqFileRequester *TempFileRequest;
if(DoSave)
TempFileRequest = &SaveFileRequest;
else
TempFileRequest = &LoadFileRequest;
TempFileRequest -> PathName = Buffer;
TempFileRequest -> Title = Title;
TempFileRequest -> dirnamescolor = 1;
TempFileRequest -> devicenamescolor = 1;
TempFileRequest -> Window = Window;
TempFileRequest -> numlines = Window -> Height >> 3;
if(DoSave)
{
TempFileRequest -> Dir = DirectoryName1;
TempFileRequest -> File = FileName1;
TempFileRequest -> Flags = FRQCACHINGM | FRQINFOGADGETM | FRQNOHALFCACHEM | FRQSAVINGM | FRQCACHEPURGEM;
TempFileRequest -> blockcolor = 1;
}
else
{
TempFileRequest -> Dir = DirectoryName2;
TempFileRequest -> File = FileName2;
TempFileRequest -> Flags = FRQCACHINGM | FRQINFOGADGETM | FRQNOHALFCACHEM | FRQLOADINGM;
TempFileRequest -> blockcolor = 1;
}
if(FileRequester(TempFileRequest))
{
Window -> Flags |= REPORTMOUSE;
return(Buffer);
}
else
{
Window -> Flags |= REPORTMOUSE;
return(NULL);
}
}
VOID
KeyConvert(struct IntuiMessage *Massage)
{
STATIC struct InputEvent Event = { NULL, IECLASS_RAWKEY, 0, 0, 0 };
if(Massage -> Class == RAWKEY)
{
if(!(Massage -> Code & IECODE_UP_PREFIX))
{
UBYTE Buffer[10];
Buffer[0] = 0;
Event . ie_Code = Massage -> Code;
Event . ie_Qualifier = Massage -> Qualifier;
Event . ie_position . ie_addr = *((APTR *)Massage -> IAddress);
if(RawKeyConvert(&Event,Buffer,10,NULL) > 0)
{
if(Buffer[0] != 155)
Massage -> Code = Buffer[0];
else
Massage -> Code = 0;
}
else
Massage -> Code = 0;
}
else
Massage -> Code = 0;
}
}
VOID
Zoom(SHORT X,SHORT Y)
{
SHORT NewX,NewY;
if(X < 0)
X = 0;
if(Y < 0)
Y = 0;
NewX = X;
NewY = Y;
if(X - (ZOOMWIDTH >> 1) > 0)
NewX -= (ZOOMWIDTH >> 1);
else
NewX = 0;
if(NewX + ZOOMWIDTH > AnotherWindow -> Width)
NewX = AnotherWindow -> Width - ZOOMWIDTH;
if(Y - (ZOOMHEIGHT >> 1) > 0)
NewY -= (ZOOMHEIGHT >> 1);
else
NewY = 0;
if(NewY + ZOOMHEIGHT > AnotherWindow -> Height)
NewY = AnotherWindow -> Height - ZOOMHEIGHT;
ZoomToWindow(AnotherWindow -> RPort,NewX,NewY,X - NewX,Y - NewY);
}
VOID
KeyAction(UBYTE Key)
{
switch(toupper(Key))
{
case 'U': undo();
break;
case 'R': redisplay_canvas();
break;
case 'E': remove_all();
put_msg("Immediate Undo will restore the figure.");
redisplay_canvas();
break;
case 'O': if (!no_object() && figure_modified)
{
if(!TwoGadRequest("Figures have been modified, please\nconfirm that you wish to continue."))
{
FlushMsg();
break;
}
}
if(DoFileRequest("Open File...",TempName,FALSE))
edit_file(TempName);
FlushMsg();
break;
case 'I': if(DoFileRequest("Insert File...",TempName,FALSE))
read_file(TempName);
FlushMsg();
break;
case 'S': if (no_object())
{
put_msg("No figure to save. Abort save operation.");
break;
}
if(DoFileRequest("Save File As...",TempName,FALSE))
save_file(TempName);
FlushMsg();
break;
case '?': status();
break;
case 'Q': quit();
FlushMsg();
break;
case 'M': if(SysBase -> LibNode . lib_Version >= 36)
{
DisplayModePrefs();
FlushMsg();
}
break;
case 'Z': if(SysBase -> LibNode . lib_Version >= 36)
{
if(!ZoomWindow)
{
if(OpenZoomWindow())
{
Zoom(AnotherWindow -> MouseX,AnotherWindow -> MouseY);
MoveCount = 0;
}
}
else
CloseZoomWindow();
}
break;
default: break;
}
}
VOID
HandleInput()
{
struct IntuiMessage *Massage;
ULONG Class,Code,Qualifier;
LONG X = 0,Y = 0,T,ScreenY;
LONG CentiX,CentiY;
BYTE KeepGoing = TRUE;
ULONG SignalSet;
struct MenuItem *MenuItem;
SHORT MenuNum;
LONG GadgetCounter;
LONG LeftEdge;
UBYTE PositionBuffer[13];
SHORT LastHit = -1;
if(IntuitionBase -> LibNode . lib_Version >= 36)
LeftEdge = Screen -> Width - (17 + 8 * 14);
else
LeftEdge = Screen -> Width - (48 + 8 * 14);
while(KeepGoing)
{
SignalSet = (1 << Window -> UserPort -> mp_SigBit);
if(ZoomWindow)
SignalSet |= (1 << ZoomWindow -> UserPort -> mp_SigBit);
SignalSet = Wait(SignalSet);
if(SignalSet & (1 << Window -> UserPort -> mp_SigBit))
{
while(Massage = (struct IntuiMessage *)GetMsg(Window -> UserPort))
{
if((GadgetCounter = HandleGadget(Window,Massage)) >= 0)
{
if(GadgetCounter <= 27)
{
if(LastHit != -1)
{
if(LastHit != GadgetCounter)
(*canvas_middlebut_proc)(X,Y);
}
LastHit = GadgetCounter;
}
switch_action(&(switches[GadgetCounter]));
}
else
{
KeyConvert(Massage);
Class = Massage -> Class;
Code = Massage -> Code;
Qualifier = Massage -> Qualifier;
if(Massage -> IDCMPWindow == AnotherWindow)
{
X = Massage -> MouseX;
Y = Massage -> MouseY;
}
else
{
struct Layer *Layer;
if(Layer = WhichLayer(&Screen -> LayerInfo,Screen -> MouseX,Screen -> MouseY))
{
if(Layer -> Window == AnotherWindow)
{
X = AnotherWindow -> MouseX;
Y = AnotherWindow -> MouseY;
}
}
if(Class == MOUSEBUTTONS)
Class = NULL;
}
ScreenY = Screen -> MouseY;
ReplyMsg(&Massage -> ExecMessage);
if(X < 0)
X = 0;
if(Y < 0)
Y = 0;
if(Qualifier & (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT))
MoveCount = 0;
if(!MoveCount++)
{
CentiX = X * 100 / PIX_PER_CM;
CentiY = Y * 100 / PIX_PER_CM;
sprintf(PositionBuffer,"X %3d %2d.%02d",X,CentiX / 100,CentiX % 100);
SetAPen(Window -> RPort,1);
SetBPen(Window -> RPort,0);
Move(Window -> RPort,0,32 * 14 + 6 + 1);
Text(Window -> RPort,PositionBuffer,12);
sprintf(PositionBuffer,"Y %3d %2d.%02d",Y,CentiY / 100,CentiY % 100);
SetAPen(Window -> RPort,1);
SetBPen(Window -> RPort,0);
Move(Window -> RPort,0,32 * 14 + 6 + 1 + 8);
Text(Window -> RPort,PositionBuffer,12);
}
if(MoveCount > 3)
MoveCount = 0;
switch(Class)
{
case MOUSEMOVE:
if(ScreenY < 11)
AnotherWindow -> Flags &= ~RMBTRAP;
else
{
AnotherWindow -> Flags |= RMBTRAP;
if(magnet_mode)
{
X = ((T = X % 5) < 3) ? X - T - 1 : X + 5 - T - 1;
Y = ((T = Y % 5) < 3) ? Y - T - 1 : Y + 5 - T - 1;
/* win_setmouseposition(figwin, X, Y);*/
}
(*canvas_locmove_proc)(X, Y);
if(ZoomWindow)
{
if(Qualifier & (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT))
MoveCount = 0;
if(!MoveCount)
Zoom(X,Y);
}
}
break;
case MOUSEBUTTONS:
if(magnet_mode)
{
X = ((T = X % 5) < 3) ? X - T - 1 : X + 5 - T - 1;
Y = ((T = Y % 5) < 3) ? Y - T - 1 : Y + 5 - T - 1;
/* win_setmouseposition(figwin, X, Y);*/
}
if(Code == SELECTDOWN)
(*canvas_leftbut_proc)(X,Y);
if(Code == MENUDOWN)
(*canvas_middlebut_proc)(X,Y);
break;
case INTUITICKS:
timerfunc();
break;
case RAWKEY:
if(Code)
{
if(LastHit == 11)
(*canvas_kbd_proc)(Code);
else
KeyAction(Code);
}
break;
case MENUPICK:
MenuNum = Code;
while(MenuNum != MENUNULL)
{
switch(ITEMNUM(MenuNum))
{
case 4: save_current_file();
FlushMsg();
break;
case 8: if(!figure_modified)
quit();
if(no_object())
quit();
if(current_file[0])
{
if(!write_file(current_file,0))
quit();
}
else
{
blink_msg();
if(DoFileRequest("Save & Quit...",TempName,TRUE))
save_and_exit(TempName);
}
break;
case 10: if(no_object())
{
put_msg("No figure to save.");
break;
}
if(DoFileRequest("Save as IFF-ILBM...",TempName,TRUE))
write_bitmap(TempName);
FlushMsg();
break;
default: KeyAction(Menus[ITEMNUM(MenuNum)] . Command);
break;
}
if(!(MenuItem = (struct MenuItem *)ItemAddress(Menu,MenuNum)))
break;
MenuNum = MenuItem -> NextSelect;
}
break;
default:
break;
}
}
}
}
if(ZoomWindow)
{
if(SignalSet & (1 << ZoomWindow -> UserPort -> mp_SigBit))
{
while(Massage = (struct IntuiMessage *)GetMsg(ZoomWindow -> UserPort))
{
Class = Massage -> Class;
ReplyMsg(&Massage -> ExecMessage);
if(Class == NEWSIZE)
{
DeleteZoomBitMap();
CreateZoomBitMap();
Zoom(AnotherWindow -> MouseX,AnotherWindow -> MouseY);
MoveCount = 0;
}
if(Class == CLOSEWINDOW)
{
CloseZoomWindow();
break;
}
}
}
}
}
}
struct Window *
openfigwin(UBYTE *Name)
{
extern MENUITEM pumenu_items[];
extern int N_SWITCHES;
extern int amicolor0,amicolor1;
extern int NUMMENUITEMS;
struct Gadget *FirstGadget = NULL,*Gadget;
LONG i;
for(i = 0 ; i < N_SWITCHES ; i++)
{
if(Gadget = (struct Gadget *)AddMyGadget((i % 3) * 32,(i / 3) * 32,32,32,switches[i] . group,switches[i] . on,switches[i] . icon -> data))
{
if(!FirstGadget)
FirstGadget = Gadget;
}
else
{
ClearGadgets();
FirstGadget = NULL;
break;
}
}
if(FirstGadget)
{
if(Menu = (struct Menu *)CreateMenu("FIG"))
{
SHORT Max = 11;
if(SysBase -> LibNode . lib_Version >= 36)
Max = 13;
for(i = 0 ; i < Max ; i++)
{
if(!AddItem(Menu,Menus[i] . Title,Menus[i] . Command))
{
ClearMenu(Menu);
Menu = NULL;
break;
}
}
if(Menu)
{
if(OpenAll(FirstGadget))
{
if(amicolor0 != -1)
SetRGB4(&Screen -> ViewPort,0,(amicolor0 >> 8) & 0xF,(amicolor0 >> 4) & 0xF,(amicolor0 ) & 0xF);
if(amicolor1 != -1)
SetRGB4(&Screen -> ViewPort,1,(amicolor1 >> 8) & 0xF,(amicolor1 >> 4) & 0xF,(amicolor1 ) & 0xF);
RastPort = AnotherWindow -> RPort;
SetAPen(RastPort,1);
init_grid();
canvas_leftbut_proc = null_proc;
canvas_middlebut_proc = null_proc;
canvas_rightbut_proc = null_proc;
canvas_kbd_proc = null_proc;
canvas_locmove_proc = null_proc;
init_switch();
SetMenuStrip(Window,Menu);
SetMenuStrip(AnotherWindow,Menu);
figwin = AnotherWindow;
/* win_setcursor(figwin,&arrow_cursor);*/
return(Window);
}
else
CloseAll();
}
}
}
return(NULL);
}
BYTE temporary_cursor = FALSE;
win_setcursor(window,cursor)
struct Window * window;
struct cursor * cursor;
{
extern struct cursor *cur_cursor;
STATIC struct cursor *static_cursor = &arrow_cursor;
SHORT i;
/* if(!cursor -> picture)*/
/* cursor = &arrow_cursor;*/
if(!temporary_cursor)
{
cur_cursor = static_cursor;
static_cursor = cursor;
}
if(cursor -> picture)
{
for(i = 0 ; i < cursor -> picture -> ylen ; i++)
Sprite[2 + 2 * i] = cursor -> picture -> data[i];
Sprite[2 + 2 * i] = Sprite[4 + 2 * i] = 0;
SetPointer(figwin,Sprite,cursor -> picture -> ylen,cursor -> picture -> xlen,-cursor -> actx,-cursor -> acty);
}
else
{
memset(Sprite,0,(2 + 16) * 2 * sizeof(UWORD));
SetPointer(figwin,Sprite,1,1,0,0);
}
}
/* INV_PAINT,MERGE,PAINT,ERASE */
int mode[] = {COMPLEMENT,JAM1,JAM2,JAM1};
set_gmode(colour)
{
if(colour == ERASE)
SetAPen(RastPort,0);
SetDrMd(RastPort,mode[colour - 1]);
}
reset_gmode()
{
SetAPen(RastPort,1);
SetDrMd(RastPort,JAM1);
}
pw_put(window,x,y,colour)
struct Window * window;
{
SetAPen(RastPort,colour);
WritePixel(RastPort,x,y);
SetAPen(RastPort,1);
}
pw_vector(window,x,y,x1,y1,colour,unknown)
struct Window * window;
{
set_gmode(colour);
Move(RastPort,x,y);
Draw(RastPort,x1,y1);
reset_gmode();
}
pw_write(window,x,y,width,height,colour,mask,u1,u2)
struct Window * window;
struct iconpic * mask;
{
if(window == figwin)
{
set_gmode(colour);
BltPattern(RastPort,(APTR)mask -> data,x,y,x + width - 1,y + height - 1,(y + 15) / 16);
reset_gmode();
}
}
pw_text(window,x,y,colour,font,string)
struct Window * window;
struct TextFont * font;
unsigned char * string;
{
set_gmode(colour);
Move(RastPort,x,y);
Text(RastPort,string,strlen(string));
reset_gmode(colour);
}
struct rastmem
{
int x,y;
char *ptr;
} RastMem[20];
int rastptr = 0;
USHORT *
mem_create(x,y)
{
int i;
char *ptr = (char *)AllocRaster(x,y);
if(!ptr)
{
fprintf(stderr,"No memory.\n");
_abort();
}
RastMem[rastptr] . x = x;
RastMem[rastptr] . y = y;
RastMem[rastptr] . ptr = ptr;
rastptr++;
if(rastptr == 20)
{
fprintf(stderr,"No memory.\n");
_abort();
}
for(i = 0 ; i < RASSIZE(x,y) ; i++)
ptr[i] = 0;
return (USHORT *)ptr;
}
mem_free()
{
int i;
for(i = 0 ; i < rastptr ; i++)
FreeRaster(RastMem[i] . ptr,RastMem[i] . x,RastMem[i] . y);
}
PR_SIZE
pf_textwidth(len,font,str)
int len;
struct TextFont * font;
char * str;
{
PR_SIZE x;
x . x = len * font -> tf_XSize;
x . y = font -> tf_YSize;
/* x . x = len * 8;*/
/* x . y = 8;*/
return x;
}
cfree(x)
char * x;
{
free(x);
}
clear_canvas()
{
set_gmode(ERASE);
SetOPen(RastPort,0);
/* RectFill(RastPort,100,10,Window -> Width - 1,Window -> Height - 1);*/
RectFill(RastPort,0,0,AnotherWindow -> Width - 1,AnotherWindow -> Height - 1);
reset_gmode();
}